/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pack;

import java.awt.Color;
import java.util.ArrayList;
import net.useobjects.AbstractMovableRotatableGroup;
import net.useobjects.Circle;
import net.useobjects.geom.Position;

/**
 *
 * @author Kovac
 */
public class Strela extends PohyblivyObjekt {

    private Circle strela;
    private final int posun = 1;

    private double angle;
    private ArrayList<Kamen> zoznamKamenov;
    private ArrayList<Strela> zoznamStriel;

    public Strela(AbstractMovableRotatableGroup parent, Position pozicia, double angle, ArrayList<Kamen> zoznamKamenov, ArrayList<Strela> zoznamStriel) {

        super(parent, pozicia);
        strela = new Circle(this, 0, 0, 5, Color.orange);
        strela.setRotation(angle);
        this.angle = angle;
        this.zoznamKamenov = zoznamKamenov;
        this.zoznamStriel = zoznamStriel;
    }

  

    @Override
    protected void process() {
        //            int index=(zoznamStriel.indexOf(getInstance()) );
        if (mozemSaPohnut(strela, zoznamKamenov) && jeVoSvete(strela)) {
            strela.moveInDirection(posun, angle);
            setPosition(strela.getPositionInRootGroup());

//                zoznamStriel.set(index,getInstance());
//                System.out.println("sss"+getInstance().getPositionInRootGroup());
        } else {
            timer.stop();
            strela.setVisible(false);
            zoznamStriel.remove(Strela.this);
            strela = null;
        }
    }

}
